package com.example.order.sentinel;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.example.order.service.UserService;
import org.springframework.stereotype.Service;

import java.util.UUID;

/**
 * @Description TODO
 * @Author JFeng
 * @Date 2024/5/17
 */
@Service
public class UserServiceImpl implements UserService {
    @Override
    @SentinelResource(value = "getUser",
            blockHandlerClass = UserServiceImpl.class,
            blockHandler = "blockHandlerGetUser")
    public String getUser() {
        return "getUser=" + UUID.randomUUID();
    }

    public static String blockHandlerGetUser(BlockException blockException) {
        return "getUser被流控";
    }
}
